package medium;

import java.util.ArrayList;
import java.util.List;

/**
 * 6. Z字型变换
 * 创建时间：2024-03-22 15:14
 * 地址：https://leetcode.cn/problems/zigzag-conversion/description/
 */
public class Z字型变换_6 {
    public static String convert(String s, int numRows) {
        int flag = 0;
        if (numRows == 1) {
            return s;
        }
        List<StringBuilder> rows = new ArrayList<>();
        for (int i = 0; i < numRows; i++) {
            rows.add(new StringBuilder());
        }
        int range = (numRows << 1) - 2;
        for (int i = 0; i < s.length(); i++) {
            rows.get(flag).append(s.charAt(i));
            if (i % range < numRows - 1) {
                flag++;
            } else {
                flag--;
            }
        }
        StringBuilder rsl = new StringBuilder();
        for (StringBuilder row : rows) {
            rsl.append(row);
        }
        return rsl.toString();
    }

    public static void main(String[] args) {
//        System.out.println(convert("AB", 1));
        System.out.println(10 << 1);
    }

}
